package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.Message;
import com.ruoyi.system.mapper.MessageMapper;
import com.ruoyi.system.service.IMessageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class MessageServiceImpl implements IMessageService {

    @Autowired
    private MessageMapper messageMapper;

    @Autowired
    private TaskServiceImpl taskService;


    @Override
    public boolean insertMessage(Message message) {
        int result = messageMapper.insertMessage(message);
        if(result > 0){
            taskService.send(message.getStudentId(), "sendMessage");
            return true;
        }
        return false;
    }

    @Override
    public List<Message> selectMessageList(int storyId) {
        return messageMapper.selectMessageList(storyId);
    }

    @Override
    public Integer selectStoryStatusCount(int storyId) {
        return messageMapper.selectStoryStatusCount(storyId);
    }
}
